package com.sinven.service;

import com.sinven.common.ApiResult;
import com.sinven.mapper.OrderMapper;
import com.sinven.mapper.PhoneMapper;
import com.sinven.pojo.*;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class PhoneServiceImpl implements PhoneService {
    @Resource
    public PhoneMapper phoneMapper;
    @Resource
    public OrderMapper orderMapper;
//缴费业务
    @Override
    public ApiResult<Order> payment(Phone phone, int id) {
        ApiResult<Order> api=new ApiResult<Order>();
        if(phoneMapper.payment(phone)>0){
            //缴费成功
        Order order=new Order();
        User user=new User();
        user.setUid(1);
            Login login=new Login();
            login.setLid(id);
            Type type=new Type();
            type.setTid(1);
        order.setUid(user);
        order.setLid(login);
        order.setTid(type);
        order.setOmoney(phone.getPstorage());
        api.setData(order);
        api.setCode(0);
        api.setCount(1);
        return api;
        }
        api.setCode(1);
        return null;
    }
}
